<?php
include'../King/hero.php';
if($islogin==1){}else exit("<script language='javascript'>window.location.href='login.php';</script>");
?>
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <title><?php echo $conf['sitename']; ?>-个人信息</title>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="default">
    <link rel="stylesheet" type="text/css" href="css/materialdesignicons.min.css">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.min.css">
    <!--表格插件css-->
    <link rel="stylesheet" href="js/bootstrap-table/bootstrap-table.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.min.css">
    <!--对话框插件css-->
    <link rel="stylesheet" type="text/css" href="js/jquery-confirm/jquery-confirm.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.min.css">
    <style>
        .layui-layer-content .input-group-addon {
            margin-right: 1.5em;
        }
    </style>
</head>

<body>
    <div class="container-fluid">

        <div class="row">

            <!-- 基本信息 -->
            <div class="col-lg-12">
                <div class="card">
                    <header class="card-header">
                        <div class="card-title">基本信息</div>
                    </header>
                    <div class="card-body">
                        <div class="Information-form">
                            <div class="mb-3">
                                <label for="nickname">昵称</label>
                                <input type="text" class="form-control" name="nickname" id="name"
                                    placeholder="输入您的昵称" value="<?php echo $conf['name']; ?>">
                            </div>
                            <div class="mb-3">
                                <label for="Signatures">个签</label>
                                <input type="text" class="form-control" name="Signatures" id="gq" placeholder="输入您的个签" value="<?php echo $conf['gq']; ?>">
                                <small class="form-text text-muted">| 符号表示换行</small>
                            </div>
                            <div class="mb-3">
                                <label for="remark">简介</label>
                                <textarea class="form-control" name="remark" id="jian" rows="3"><?php echo $conf['jian']; ?></textarea>
                            </div>
                            <div class="mb-3">
                                <label for="nickname">设置标题【今日运势】</label>
                                <input type="text" class="form-control"id="ystitle" placeholder="设置标题【今日运势】" value="<?php echo $conf['ystitle']; ?>">
                            </div>
                            <div class="mb-3">
                                <label for="fortune">设置星星数量</label>
                                <select class="form-select" aria-label="默认下拉选择示例" name="FortuneStar"id="ys"default="<?php echo $conf['ys']; ?>">
                                    <option value="1">一颗星星</option>
                                    <option value="2">二颗星星</option>
                                    <option value="3">三颗星星</option>
                                    <option value="4">四颗星星</option>
                                    <option value="5">五颗星星</option>
                                    <option value="0">清除</option>
                                </select>
                            </div>
                            <button class="btn btn-primary"onclick="set()">保存</button>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 作息时间 -->
            <div class="col-lg-4">
                <div class="card">
                    <header class="card-header">
                        <div class="card-title">作息时间</div>
                    </header>
                    <div class="card-body">
                        <div class="bootstrap-table bootstrap5">
                            <div class="fixed-table-toolbar">
                                <div class="bs-bars float-left">
                                    <div id="toolbar" class="toolbar-btn-action">
                                        <button onclick="adda()" type="button" class="btn btn-primary me-1">
                                            <span class="mdi mdi-plus" aria-hidden="true"></span>新增
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div class="fixed-table-body" style="margin-top: 1.5em;">
                                <table id="table" class="table table-bordered table-hover table-striped lyear-table">
                                    <thead class="">
                                        <tr>
                                            <th title="文字" style="text-align: center; " data-field="author">
                                                <div class="th-inner">文字</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center; " data-field="dynasty">
                                                <div class="th-inner">图标</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th data-field="operate">
                                                <div class="th-inner" style="text-align: center;">操作</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        
                                        <?php                                            
$rs=$DB->query("SELECT * FROM xf_zx WHERE 1 order by id desc");
while($res = $DB->fetch($rs))
{             
?>
                    <tr data-num="<?=$res["id"]?>">
                <td style="text-align: center;"><?=$res["txt"]?></td>
                 <td style="text-align: center;"><img src="<?=$res["img"]?>" class="img-fluid clickImg"style="width: 1.5em;"></td>
                <td style="text-align: center;">
                    <a class="btn btn-sm btn-default del-btn-site" title="" data-bs-toggle="tooltip" data-bs-original-title="删除"onclick="del(<?=$res["id"]?>)" aria-label="删除"><i class="mdi mdi-window-close"></i>
                    </a>
                </td>
            </tr>
<?php
}
?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="fixed-table-footer"></div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 今日运势 -->
            <div class="col-lg-4">
                <div class="card">
                    <header class="card-header">
                        <div class="card-title">今日运势</div>
                    </header>
                    <div class="card-body">
                        <div class="bootstrap-table bootstrap5">
                            <div class="fixed-table-toolbar">
                                <div class="bs-bars float-left">
                                    <div id="toolbar" class="toolbar-btn-action">
                                        <button onclick="addab()" type="button" class="btn btn-primary me-1">
                                            <span class="mdi mdi-plus" aria-hidden="true"></span>新增
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div class="fixed-table-body" style="margin-top: 1.5em;">
                                <table id="table" class="table table-bordered table-hover table-striped lyear-table">
                                    <thead class="">
                                        <tr>
                                            <th title="文字" style="text-align: center; " data-field="author">
                                                <div class="th-inner">文字</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center; " data-field="dynasty">
                                                <div class="th-inner">百分比(不用写%符号)</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th data-field="operate">
                                                <div class="th-inner" style="text-align: center;">操作</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        
                                        <?php                                            
$rs=$DB->query("SELECT * FROM xf_ys WHERE 1 order by id desc");
while($res = $DB->fetch($rs))
{             
?>
            <tr data-num="<?=$res["id"]?>">
                <td style="text-align: center;"><?=$res["txt"]?></td>
                <td style="text-align: center; "><?=$res["img"]?>%</td>
                <td style="text-align: center;">
                    <a class="btn btn-sm btn-default del-btn-site" title="" data-bs-toggle="tooltip" data-bs-original-title="删除"onclick="dela(<?=$res["id"]?>)" aria-label="删除"><i class="mdi mdi-window-close"></i>
                    </a>
                </td>
            </tr>
<?php
}
?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="fixed-table-footer"></div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 新增图标 -->
            <div class="col-lg-4">
                <div class="card">
                    <header class="card-header">
                        <div class="card-title">新增首页图标</div>
                    </header>
                    <div class="card-body">
                        <div class="bootstrap-table bootstrap5">
                            <div class="fixed-table-toolbar">
                                <div class="bs-bars float-left">
                                    <div id="toolbar" class="toolbar-btn-action">
                                        <button onclick="addac()" type="button" class="btn btn-primary me-1">
                                            <span class="mdi mdi-plus" aria-hidden="true"></span>新增
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div class="fixed-table-body" style="margin-top: 1.5em;">
                                <table id="table" class="table table-bordered table-hover table-striped lyear-table">
                                    <thead class="">
                                        <tr>
                                            <th style="text-align: center; " data-field="author">
                                                <div class="th-inner">图标链接</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center; " data-field="dynasty">
                                                <div class="th-inner">跳转链接</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th data-field="operate">
                                                <div class="th-inner" style="text-align: center;">操作</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                            
                                            <?php                                            
    $rs=$DB->query("SELECT * FROM xf_tb WHERE 1 order by id desc");
    while($res = $DB->fetch($rs))
    {             
    ?>
                <tr data-num="<?=$res["id"]?>">
                    <td style="text-align: center;"><img src="<?=$res["img"]?>" class="img-fluid clickImg"style="width: 1.5em;"></td>
                    <td style="text-align: center; "><?=$res["txt"]?></td>
                    <td style="text-align: center;">
                        <a class="btn btn-sm btn-default del-btn-site" title="" data-bs-toggle="tooltip" data-bs-original-title="删除"onclick="delb(<?=$res["id"]?>)" aria-label="删除"><i class="mdi mdi-window-close"></i>
                        </a>
                    </td>
                </tr>
    <?php
    }
    ?>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="fixed-table-footer"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

    </div>

    </div>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/popper.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/main.min.js"></script>
    <!--表格插件js-->
    <script src="js/bootstrap-table/bootstrap-table.js"></script>
    <script src="js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <!--对话框插件js-->
    <script type="text/javascript" src="js/jquery-confirm/jquery-confirm.min.js"></script>
     <script type="text/javascript" src="js/jquery-tagsinput/jquery.tagsinput.min.js"></script>
    
    <script type="text/javascript" src="js/main.min.js"></script>
    <script type="text/javascript" src="js/template-web.js"></script>
  
<script src="//lib.baomitu.com/layer/2.3/layer.js"></script>
    <script>
function set(){//系统配置
        var name= $("#name").val(); 
        var gq= $("#gq").val(); 
        var jian= $("#jian").val(); 
        var ys= $("#ys").val(); 
         var ystitle= $("#ystitle").val(); 
		  	$.ajax({
				type : "POST",
				url : "./ajax.php?act=czbasic",
				data : {name,gq,jian,ys,ystitle},
				dataType : 'json',
				timeout:10000,
				success(data) {
					  $.alert({
                                title: '提示',
                                content: '提交成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
					  if(data.code==1){
						setTimeout(function () {
							location.href="./pages_profile.php";
						}, 1000); //延时1秒跳转
					  }
				},
				error:function(data){
					$.alert({
                                title: '提示',
                                content: '提交失败！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
					}
			});
		  	
}

function del(id) {
		$.ajax({
			type : "POST",
			url : "./ajax.php?act=delzx",
			data : {id:id},
			dataType : "json",
			success : function(data) {
			
				if(data.code == 1){
					$.alert({
                                title: '提示',
                                content: '删除成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
					window.location.reload();
					}else{
						$.alert({
                                title: '提示',
                                content: '删除失败！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
						window.location.reload();
					}
					}
					});
		
}
function dela(id) {
		$.ajax({
			type : "POST",
			url : "./ajax.php?act=delys",
			data : {id:id},
			dataType : "json",
			success : function(data) {
			
				if(data.code == 1){
					$.alert({
                                title: '提示',
                                content: '删除成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
					window.location.reload();
					}else{
						$.alert({
                                title: '提示',
                                content: '删除失败！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
						window.location.reload();
					}
					}
					});
		
}
function delb(id) {
		$.ajax({
			type : "POST",
			url : "./ajax.php?act=deltb",
			data : {id:id},
			dataType : "json",
			success : function(data) {
			
				if(data.code == 1){
					$.alert({
                                title: '提示',
                                content: '删除成功！',
                                icon: 'mdi mdi-check-bold',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-pink'
                                    }
                                }
                            })
					window.location.reload();
					}else{
						$.alert({
                                title: '提示',
                                content: '删除失败！',
                                icon: 'mdi mdi-alert',
                                animation: 'scale',
                                closeAnimation: 'scale',
                                buttons: {
                                    okay: {
                                        text: 'OK',
                                        btnClass: 'btn-red'
                                    }
                                }
                            })
						window.location.reload();
					}
					}
					});
		
}
function addzx() {
    var txt=$("#txt").val();
	var img=$("#img").val();
	if(txt == '' || img == ''){
        layer.msg("禁止留空",{icon:2,shift:6});
        return false;
    }
 $.ajax({
    type: "POST",
    url: "./ajax.php?act=addzx",
    data: {txt:txt,img:img},
    dataType: "json",
    success: function(data) {
            
            if (data.code == 1) {
               $.alert({ title: '', content: data.msg});
                window.location.href = data.url;
      } else {
        $.alert({
                            title: '',
                            content: "添加失败！",
                            type: 'red'
                        });
        return false;
      }
    }
  });
}
function addys() {
    var txt=$("#txt").val();
	var img=$("#img").val();
	if(txt == '' || img == ''){
        layer.msg("禁止留空",{icon:2,shift:6});
        return false;
    }
	
 $.ajax({
    type: "POST",
    url: "./ajax.php?act=addys",
    data: {txt:txt,img:img},
    dataType: "json",
    success: function(data) {
            
            if (data.code == 1) {
               $.alert({ title: '', content: data.msg});
                window.location.href = data.url;
      } else {
        $.alert({
                            title: '',
                            content: "添加失败！",
                            type: 'red'
                        });
        return false;
      }
    }
  });
}
function addtb() {
    var txt=$("#txt").val();
	var img=$("#img").val();
	if(txt == '' || img == ''){
        layer.msg("禁止留空",{icon:2,shift:6});
        return false;
    }
 $.ajax({
    type: "POST",
    url: "./ajax.php?act=addtb",
    data: {txt:txt,img:img},
    dataType: "json",
    success: function(data) {
            
            if (data.code == 1) {
               $.alert({ title: '', content: data.msg});
                window.location.href = data.url;
      } else {
        $.alert({
                            title: '',
                            content: "添加失败！",
                            type: 'red'
                        });
        return false;
      }
    }
  });
}
function adda() {
	var ii = layer.load(2, {shade:[0.1,'#fff']});
	$.ajax({
		type : 'GET',
		url : 'ajax.php?act=addzxa',
		dataType : 'json',
		success : function(data) {
			layer.close(ii);
			if(data.code == 0){
				layer.open({
				  type: 1,
				  title: '添加作息',
				  skin: 'layui-layer-rim',
                  success(layero, index) {
                      $(layero).find('.layui-layer-content').addClass('layui-layer-btn layui-layer-btn-'); 
                  },
				  content: data.data
				});
			}else{
				layer.alert(data.msg);
			}
		},
		error:function(data){
			layer.msg('服务器错误');
			return false;
		}
	});
}
function addab() {
	var ii = layer.load(2, {shade:[0.1,'#fff']});
	$.ajax({
		type : 'GET',
		url : 'ajax.php?act=addysa',
		dataType : 'json',
		success : function(data) {
			layer.close(ii);
			if(data.code == 0){
				layer.open({
				  type: 1,
				  title: '添加运势',
				  skin: 'layui-layer-rim',
                  success(layero, index) {
                      $(layero).find('.layui-layer-content').addClass('layui-layer-btn layui-layer-btn-'); 
                  },
				  content: data.data
				});
			}else{
				layer.alert(data.msg);
			}
		},
		error:function(data){
			layer.msg('服务器错误');
			return false;
		}
	});
}
function addac() {
	var ii = layer.load(2, {shade:[0.1,'#fff']});
	$.ajax({
		type : 'GET',
		url : 'ajax.php?act=addtba',
		dataType : 'json',
		success : function(data) {
			layer.close(ii);
			if(data.code == 0){
				layer.open({
				  type: 1,
				  title: '添加图标',
				  skin: 'layui-layer-rim',
                  success(layero, index) {
                      $(layero).find('.layui-layer-content').addClass('layui-layer-btn layui-layer-btn-'); 
                  },
				  content: data.data
				});
			}else{
				layer.alert(data.msg);
			}
		},
		error:function(data){
			layer.msg('服务器错误');
			return false;
		}
	});
}
// 添加图标
function addico() {
	var ii = layer.load(2, {shade:[0.1,'#fff']});
	$.ajax({
		type : 'GET',
		url : 'ajax.php?act=addtba',
		dataType : 'json',
		success : function(data) {
			layer.close(ii);
			if(data.code == 0){
				layer.open({
				  type: 1,
				  title: '添加图标',
				  skin: 'layui-layer-rim',
                  success(layero, index) {
                      $(layero).find('.layui-layer-content').addClass('layui-layer-btn layui-layer-btn-'); 
                  },
				  content: data.data
				});
			}else{
				layer.alert(data.msg);
			}
		},
		error:function(data){
			layer.msg('服务器错误');
			return false;
		}
	});
    
}
    </script>
</body>

</html>